﻿using Google.ProtocolBuffers.Descriptors;
using Se.Model;
using Se.Protocol.T4Template;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Se.Model.Generator
{
    static class Program
    {
        static void Main()
        {
            Console.WriteLine("开始生成代码");
            MyServerTemplate template = new MyServerTemplate();
            var serverCode = template.TransformText();
            string curPath = Directory.GetCurrentDirectory();
            string fileName = "GeneratorCodeForServer.cs";
            var fullName = string.Format(System.Configuration.ConfigurationManager.AppSettings["servercodepath"], curPath, fileName);
            File.WriteAllText(fullName, serverCode);
            Console.WriteLine("成功生成代码[{0}]", fileName);

            MyClientTemplate clientTemplate = new MyClientTemplate();
            var clientCode = clientTemplate.TransformText();
            fileName = "GeneratorCodeForClient.cs";
            fullName = string.Format(System.Configuration.ConfigurationManager.AppSettings["clientcodepath"], curPath, fileName);
            File.WriteAllText(fullName, clientCode);
            Console.WriteLine("成功生成代码[{0}]", fileName);

            return;

        }

    }
}
